<template>
  <j-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    
    <a-spin :spinning="confirmLoading">
      <a-form-model ref="form" :model="model" :rules="validatorRules">
      
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="redocid" label="redocid">
          <a-input placeholder="请输入redocid" v-model="model.redocid" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="retype" label="retype">
          <a-input placeholder="请输入retype" v-model="model.retype" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="freightbillno" label="freightbillno">
          <a-input placeholder="请输入freightbillno" v-model="model.freightbillno" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="companyid" label="companyid">
          <a-input placeholder="请输入companyid" v-model="model.companyid" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="agentid" label="agentid">
          <a-input placeholder="请输入agentid" v-model="model.agentid" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactid" label="contactid">
          <a-input placeholder="请输入contactid" v-model="model.contactid" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="storerid" label="storerid">
          <a-input placeholder="请输入storerid" v-model="model.storerid" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="memo" label="memo">
          <a-input placeholder="请输入memo" v-model="model.memo" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="inputmanid" label="inputmanid">
          <a-input placeholder="请输入inputmanid" v-model="model.inputmanid" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="credate" label="credate">
          <a-date-picker v-model="model.credate"/>
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="entryid" label="entryid">
          <a-input placeholder="请输入entryid" v-model="model.entryid" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="usestatus" label="usestatus">
          <a-input placeholder="请输入usestatus" v-model="model.usestatus" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="twoinvoiceinflag" label="twoinvoiceinflag">
          <a-input placeholder="请输入twoinvoiceinflag" v-model="model.twoinvoiceinflag" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="filecount" label="filecount">
          <a-input placeholder="请输入filecount" v-model="model.filecount" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="placereturnid" label="placereturnid">
          <a-input placeholder="请输入placereturnid" v-model="model.placereturnid" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zxMemo" label="zxMemo">
          <a-input placeholder="请输入zxMemo" v-model="model.zxMemo" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zxRecmanid" label="zxRecmanid">
          <a-input placeholder="请输入zxRecmanid" v-model="model.zxRecmanid" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zxRecdate" label="zxRecdate">
          <a-date-picker v-model="model.zxRecdate"/>
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jdOrderId" label="jdOrderId">
          <a-input placeholder="请输入jdOrderId" v-model="model.jdOrderId" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="b2bShopFlag" label="b2bShopFlag">
          <a-input placeholder="请输入b2bShopFlag" v-model="model.b2bShopFlag" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="b2bOrderId" label="b2bOrderId">
          <a-input placeholder="请输入b2bOrderId" v-model="model.b2bOrderId" />
        </a-form-model-item>
		
      </a-form-model>
    </a-spin>
  </j-modal>
</template>

<script>
  import { httpAction } from '@/api/manage'
  import moment from "moment"

  export default {
    name: "BmsStReDocModal",
    data () {
      return {
        title:"操作",
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },

        confirmLoading: false,
        validatorRules:{
        redocid:[{ required: true, message: '请输入redocid!' }],
        },
        url: {
          add: "/inca/bmsStReDoc/add",
          edit: "/inca/bmsStReDoc/edit",
        },
      }
    },
    created () {
    },
    methods: {
      add () {
        //初始化默认值
        this.edit({});
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      close () {
        this.$emit('close');
        this.visible = false;
        this.$refs.form.clearValidate();
      },
      handleOk () {
        const that = this;
        // 触发表单验证
         this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })
          }else{
             return false;
          }
        })
      },
      handleCancel () {
        this.close()
      },


    }
  }
</script>

<style lang="less" scoped>

</style>